package com.esunrising.esungsc.service.impl;


import com.esunrising.esungsc.dao.BaseDao;
import com.esunrising.esungsc.entity.BaseEntity;
import com.esunrising.esungsc.service.BaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

@Service
public abstract class BaseServiceImpl<D extends BaseDao<T>, T extends BaseEntity> implements BaseService<T> {

    @Autowired
    protected D dao;

    @Override
    public void save(T entity) {
        // TODO: 从上下文中获取并设置DWBH、ORGID、ORGCODE、LEDGER
        entity.setEsunApiUpdate(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
        dao.save(entity);
    }
}
